package ezXpns.tests;

import static org.junit.Assert.*;

import java.util.Date;
import java.util.Random;

import org.junit.Test;

import com.google.gson.Gson;

import ezXpns.BudgetChange;
import ezXpns.SerializationConfig;


//@author A0086934R
public class SerializationConfigTest {

	@Test
	public void test() {
		Gson gson = SerializationConfig.getGson();
		Random random = new Random();
		Date date = new Date(random.nextLong());
		String json = gson.toJson(date);
		Date date2 = gson.fromJson(json, Date.class);
		assertEquals(date, date2);
		String json2 = gson.toJson(date2);
		assertEquals(json, json2);
		
		BudgetChange expense1 = new BudgetChange();
		expense1.setDate(date);
		BudgetChange expense2 = new BudgetChange();
		expense2.setDate(expense1.getDate());
		String str1 = gson.toJson(expense1);
		String str2 = gson.toJson(expense2);		
		assertEquals(str1, str2);
	}
}
